import { Module } from '@nestjs/common';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { join } from 'path';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { SequelizeModule } from '@nestjs/sequelize';
import { ServeStaticModule } from '@nestjs/serve-static';
import { PrometheusModule } from '@willsoto/nestjs-prometheus';

@Module({
    imports: [
        PrometheusModule.register(),
        ServeStaticModule.forRoot({
            rootPath: join(__dirname, '../../public'),
        }),
        SequelizeModule.forFeature([], 'lia_web_rtp'),
        SequelizeModule.forRoot({
            dialect: 'mysql',
            name: 'lia_web_rtp',
            autoLoadModels: true,
            synchronize: false,
            timezone: '+08:00',
            logging: false,
            query: { raw: true },
            host: process.env.MYSQL_HOST || 'localhost',
            port: Number(process.env.MYSQL_PORT) || 3306,
            username: process.env.MYSQL_USER || 'root',
            password: process.env.MYSQL_PASSWORD || 'Leaper@123',
            database: process.env.MYSQL_DATABASE || 'lia_web_rtp',
        }),
        ClientsModule.register([
            {
                name: 'HTTP_SERVICE',
                transport: Transport.TCP,
            },
        ]),
    ],
    controllers: [AppController],
    providers: [AppService],
})
export class AppModule {}
